package org.jadestudio.dsdown.action;
import java.util.Map;
import java.util.Properties;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.jadestudio.dsdown.service.ManageLoginService;
import org.jadestudio.dsdown.util.SysInfo;
import org.springframework.stereotype.Component;

@Component(value="/jadestudio/portal")
public class ManagePageAction  extends Action {
	@Resource
	private ManageLoginService manageLoginService;
	private Map<String,Long> memUsed;
	private Properties sysinfo;
	public ManagePageAction(){}
	/**
	 * 引导至登录页面
	 */
	@SuppressWarnings("unchecked")
	public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception{
		int sessionFlag=manageLoginService.userSessionRecheck(request);
		if(sessionFlag>0){
			memUsed=SysInfo.getMemUsedState();
			sysinfo=SysInfo.getSysInfo();
			request.setAttribute("memused",memUsed);
			request.setAttribute("sysinfo",sysinfo);
			return mapping.findForward("havesession");//直接登录
		}
		return mapping.findForward("success");//引导至登录页面
	}
}
